library(dplyr)
library(magrittr)
library(tidyr)
library(ggplot2)

dat <- rio::import("data/Demo_book_country_3.dta")


dat_sm <- dat %>%
  group_by(year) %>%
  summarize(mean_poly = mean(v2x_polyarchy_imp_100, na.rm = T))

p <- ggplot(dat_sm, aes(x = year, y = mean_poly)) +
  geom_line() +
  xlim(c(1789, 2020)) + 
  theme(panel.grid.minor = element_blank(), 
        panel.grid.major = element_blank(),
        panel.border = element_blank(),
        panel.background = element_blank(),
        axis.line = element_line(color = "black")) + 
  labs(x = "Year", y = "Polyarchy")

# ggsave(p, file = "figure_2_4.png", height = 8.5, width = 11)
ggsave(p, file = "output/figure_2_3.tiff", height = 8.5, width = 11, dpi = 300)
